﻿using MediatR;
using SystemHYS.API.Application.command.ProductionRequisitionCommand;
using SystemHYS.Infrstructre.Interface;
using SystemHYS.Infrstructre;
using SystemHYS.Domian;
namespace SystemHYS.API.Application.commandler.ProductionRequisitionCommandler
{
    public class ProductionRequisitionUpdateCommandler : IRequestHandler<ProductionRequisitionUpdateCommand, int>
    {
        IRawMaterialProductionRepository rawMaterialProductionRepository;
        IProductionRequisitionRepository productionRequisitionRepository;
        public SystemCoretext db;
        public ProductionRequisitionUpdateCommandler(IRawMaterialProductionRepository rawMaterialProductionRepository, IProductionRequisitionRepository productionRequisitionRepository, SystemCoretext db)
        {
            this.rawMaterialProductionRepository = rawMaterialProductionRepository;
            this.productionRequisitionRepository = productionRequisitionRepository;
            this.db = db;
        }
        public async Task<int> Handle(ProductionRequisitionUpdateCommand request, CancellationToken cancellationToken)
        {
            var list = new ProductionRequisition
            {
                productionRequisitionId = request.productionRequisitionId,
                requisitionNumber = request.requisitionNumber,
                requisitionName = request.requisitionName,
                requisitionDate = request.requisitionDate,
                requisitionPerson = request.requisitionPerson,
                workOrderName = request.workOrderName,
                workOrderOrder = request.workOrderOrder,
                taskName = request.taskName,
                taskOrder = request.taskOrder,
                processRoute = request.processRoute,
                processName = request.processName,
                remark = request.remark,
                AddName = request.AddName,
                AddTime = request.AddTime,
                UpdateName = "李明",
                UpdateTime = DateTime.Now.ToUniversalTime(),
            };
            return await productionRequisitionRepository.UpdateAsyn(list);
        }
    }
}
